{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "326ff1a2-fe02-4b73-9bf6-d2008611cfe7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# [VNPY3.0解析——回测执行和优化思路](https://zhuanlan.zhihu.com/p/1512133363)\n",
    "from vnpy.trader.constant import Interval\n",
    "from vnpy.trader.database import get_database"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "381eb962-475e-4586-8120-1ba32a5f9749",
   "metadata": {},
   "outputs": [],
   "source": [
    "database_manager = get_database()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "b416479d-6ffe-4c63-837d-7e53201da85f",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "from vnpy.trader.optimize import OptimizationSetting\n",
    "from vnpy_ctastrategy.backtesting import BacktestingEngine\n",
    "from vnpy_ctastrategy.strategies.atr_rsi_strategy import AtrRsiStrategy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f27b7842-ca18-41bf-83ae-d0aa0f836e10",
   "metadata": {},
   "outputs": [],
   "source": [
    "# engine = BacktestingEngine()\n",
    "# engine.set_parameters(\n",
    "#     vt_symbol=\"XXXX.LOCAL\",\n",
    "#     interval=\"1m\",\n",
    "#     start=datetime(2025, 7, 1),\n",
    "#     end=datetime(2025, 7, 30),\n",
    "#     rate=0.3 / 10000,\n",
    "#     slippage=0.2,\n",
    "#     size=300,\n",
    "#     pricetick=0.1,\n",
    "#     capital=1_000_000,\n",
    "# )\n",
    "# engine.add_strategy(AtrRsiStrategy, {})"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
